import Cookies from 'js-cookie'

const sessionStorage = window.sessionStorage;
export class Auth {
  /*/!**
   * 存储老师查询出的课程信息
    * @returns {any|null}
   *!/
  /!*static getMyCourse() {
    const myCourse = sessionStorage.getItem('user.myCourse');
    return myCourse ? JSON.parse(sessionStorage.getItem('user.myCourse')) : null
  }

  static setMyCourse(value) {
    return sessionStorage.setItem('user.myCourse', JSON.stringify(value));
  }*!/

  /!**
   * 储存当前课程信息
   * @returns {any|null}
   *!/
  static getCurrentCourse() {
    const currentCourse = sessionStorage.getItem('user.currentCourse');
    return currentCourse ? JSON.parse(sessionStorage.getItem('user.currentCourse')) : null
  }

  static setCurrentCourse(value) {
    return sessionStorage.setItem('user.currentCourse', JSON.stringify(value));
  }

  /!**
   * 储存任务信息
   * @returns {any|null}
   *!/
  static getMyTask() {
    const myTask = sessionStorage.getItem('user.myTask');
    return myTask ? JSON.parse(sessionStorage.getItem('user.myTask')) : null
  }

  static setMyTask(value) {
    return sessionStorage.setItem('user.myTask', JSON.stringify(value));
  }*/


  static setUserInfo(value = {}) {
    return sessionStorage.setItem('user.userInfo', JSON.stringify(value));
  }

  static getUserInfo() {
    const userInfo = sessionStorage.getItem('user.userInfo');
    return userInfo ? JSON.parse(sessionStorage.getItem('user.userInfo')) : {}
  }

  static setCurrentCourseId(value = {}) {
    return sessionStorage.setItem('courseId', JSON.stringify(value));
  }

  static getCurrentCourseId() {
    const courseId = sessionStorage.getItem('courseId');
    return courseId ? JSON.parse(sessionStorage.getItem('courseId')) : {}
  }

  static removeCurrentCourseId() {
    return sessionStorage.removeItem('courseId')
  }

  static setCurrentTaskId(value = {}) {
    return sessionStorage.setItem('taskId', JSON.stringify(value));
  }

  static getCurrentTaskId() {
    const courseId = sessionStorage.getItem('taskId');
    return courseId ? JSON.parse(sessionStorage.getItem('taskId')) : {}
  }

  static removeCurrentTaskId() {
    return sessionStorage.removeItem('taskId')
  }

/*  static removeMyCourse() {
    return sessionStorage.removeItem('user.myCourse');
  }

  static removeCurrentCourse() {
    return sessionStorage.removeItem('user.currentCourse');
  }

  static removeMyTask() {
    return sessionStorage.removeItem('user.myTask');
  }*/

  static removeUserInfo() {
    return sessionStorage.removeItem('user.userInfo')
  }

  static setAccountPwd(value = {}) {
    return sessionStorage.setItem('user.accountPwd', JSON.stringify(value))
  }

  static getAccountPwd() {
    const accountPwd = sessionStorage.getItem('user.accountPwd');
    return accountPwd ? JSON.parse(sessionStorage.getItem('user.accountPwd')) : null
  }

  static removeAccountPwd() {

    return sessionStorage.removeItem('user.accountPwd')
  }

  static setLogin() {
    return sessionStorage.setItem('isLogin', true)
  }

  static getLogin() {
    return sessionStorage.getItem('isLogin')
  }

  static removeLogin() {
    return sessionStorage.removeItem('isLogin')
  }

  static setToken(value) {
    return sessionStorage.setItem('user.token', value)
  }

  static getToken() {
    return sessionStorage.getItem('user.token')
  }

  static removeToken() {
    return sessionStorage.removeItem('user.token')
  }
}

